package com.atguigu.tingshu.account.service;

import com.atguigu.tingshu.model.account.UserAccount;
import com.atguigu.tingshu.model.account.UserAccountDetail;
import com.atguigu.tingshu.vo.account.AccountDeductVo;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;

import java.math.BigDecimal;

public interface UserAccountService extends IService<UserAccount> {


    /**
     * 初始化账户金额
     * @param userId
     */
    void initAccount(Long userId);

    /**
     * 获取用户可用金额
     * @param userId
     * @return
     */
    BigDecimal getAvailableAmount(Long userId);

    /**
     * 检查及扣减金额
     * @param accountDeductVo
     * @return
     */
    Boolean checkAndDeduct(AccountDeductVo accountDeductVo);


    /**
     * 添加用户账户明细
     * @param userId
     * @param title
     * @param type
     * @param amount
     * @param orderNo
     */
    void addUserAccountDetail(Long userId, String title, String type, BigDecimal amount, String orderNo);

    /**
     *  查看消费记录
     * @param userAccountDetailPage
     * @param userId
     * @return
     */
    IPage<UserAccountDetail> findUserConsumePage(Page<UserAccountDetail> userAccountDetailPage, Long userId);

    /**
     * 查看充值记录
     * @param userAccountDetailPage
     * @param userId
     * @return
     */
    IPage<UserAccountDetail> findUserRechargePage(Page<UserAccountDetail> userAccountDetailPage, Long userId);
}
